home *** CD-ROM | disk | FTP | other *** search
/ Small Time Crooks Press Kit / Small Time Crooks Press Kit.iso / pc / Small Time Crooks.dxr / Scripts_19_Downloading Message Behavior.ls < prev    next >
Encoding:
Text File  |  2000-04-30  |  7.6 KB  |  257 lines

  1. property pFunction, pFolderName, ancestor
  2. global gDownloadTexts, gDownloadPhotos, gVoid
  3.  
  4. on beginSprite me
  5.   set name to the name of the member of sprite the spriteNum of me
  6.   if name contains "download" then
  7.     set pFunction to #InitDownLoad
  8.   end if
  9.   if name contains "box" then
  10.     set pFunction to #box
  11.   end if
  12.   if name contains "message" then
  13.     set pFunction to #message
  14.   end if
  15.   if name contains "okay" then
  16.     set pFunction to #CompleteDownLoad
  17.   end if
  18.   if name contains "cancel" then
  19.     set pFunction to #Cancel
  20.   end if
  21.   if name contains "blocker" then
  22.     set pFunction to #blocker
  23.   end if
  24.   case pFunction of
  25.     #InitDownLoad:
  26.       set ancestor to new(script "Bitmap But 1", the spriteNum of me, 3, 0)
  27.     #CompleteDownLoad, #Cancel, #blocker:
  28.       set ancestor to new(script "Bitmap But 1", the spriteNum of me, 3, 0)
  29.       hide(me)
  30.     otherwise:
  31.       set ancestor to gVoid
  32.       hide(me)
  33.   end case
  34. end
  35.  
  36. on MouseUpAction me
  37.   case pFunction of
  38.     #InitDownLoad:
  39.       InitDownLoad(me)
  40.     #CompleteDownLoad:
  41.       set userDeterminesDestination to 0
  42.       CompleteDownLoad(userDeterminesDestination)
  43.     #blocker:
  44.       nothing()
  45.     #Cancel:
  46.       sendAllSprites(#ClearOutDownload)
  47.   end case
  48. end
  49.  
  50. on MouseDownAction me
  51.   nothing()
  52. end
  53.  
  54. on MouseEnterAction me
  55.   nothing()
  56. end
  57.  
  58. on MouseLeaveAction me
  59.   nothing()
  60. end
  61.  
  62. on hide me
  63.   if the locH of sprite the spriteNum of me > -500 then
  64.     set the locH of sprite the spriteNum of me to the locH of sprite the spriteNum of me - 1000
  65.   end if
  66. end
  67.  
  68. on show me
  69.   if the locH of sprite the spriteNum of me < -500 then
  70.     set the locH of sprite the spriteNum of me to the locH of sprite the spriteNum of me + 1000
  71.   end if
  72. end
  73.  
  74. on InitDownLoad me
  75.   if not (listp(gDownloadPhotos) and listp(gDownloadTexts)) then
  76.     exit
  77.   end if
  78.   if not (count(gDownloadPhotos) or count(gDownloadTexts)) then
  79.     exit
  80.   end if
  81.   if the platform contains "16" then
  82.     set pFolderName to char 1 to 8 of the movieName
  83.   else
  84.     set pFolderName to the movieName
  85.   end if
  86.   if offset(".", pFolderName) then
  87.     set pFolderName to char 1 to offset(".", pFolderName) - 1 of pFolderName
  88.   end if
  89.   if the platform contains "Windows" then
  90.     if DirectoryExists(getOSDirectory() & "\DESKTOP") = 0 then
  91.       sendAllSprites(#DownloadMessage, pFolderName)
  92.     else
  93.       set userDeterminesDestination to 1
  94.       CompleteDownLoad(userDeterminesDestination)
  95.     end if
  96.   else
  97.     sendAllSprites(#DownloadMessage, pFolderName)
  98.   end if
  99. end
  100.  
  101. on DownloadMessage me, inputFolderName
  102.   set pFolderName to inputFolderName
  103.   case pFunction of
  104.     #CompleteDownLoad, #Cancel:
  105.       sendSprite(the spriteNum of me, #setstate, #norm)
  106.       show(me)
  107.     #blocker, #box:
  108.       show(me)
  109.     #message:
  110.       put "Download Selected Images to your Desktop?" into field the name of the member of sprite the spriteNum of me
  111.       show(me)
  112.   end case
  113. end
  114.  
  115. on ClearOutDownload me
  116.   case pFunction of
  117.     #CompleteDownLoad, #Cancel, #box, #message, #blocker:
  118.       hide(me)
  119.   end case
  120. end
  121.  
  122. on CompleteDownLoad userDeterminesDestination
  123.   sendAllSprites(#ClearOutDownload)
  124.   updateStage()
  125.   if the platform contains "windows" then
  126.     set CTLF to RETURN & numToChar(10)
  127.   else
  128.     set CTLF to RETURN
  129.   end if
  130.   set downloadPhotoFiles to []
  131.   set photosString to EMPTY
  132.   repeat with photoName in gDownloadPhotos
  133.     append(downloadPhotoFiles, GetPhototFileName(photoName))
  134.   end repeat
  135.   set copyright to CTLF & " ¬© 2000 ‚Ñ¢DreamWorks LLC.  All rights reserved.  Permission granted for reproduction in newspapers and periodicals only.  Use of this photography in any manner including but not limited to publication in books, retrospectives, biographies, or in connection with the advertising of posters or any other product or service, permitted only with written permission of the copyright proprietor." & CTLF & CTLF
  136.   set n to 1
  137.   repeat with photoName in gDownloadPhotos
  138.     set photoDescription to GetPhototDescription(photoName)
  139.     put getAt(downloadPhotoFiles, n) && "--" && photoDescription & CTLF & CTLF after photosString
  140.     set n to n + 1
  141.   end repeat
  142.   set indexText to "Small Time Crooks" & CTLF & "Press Kit Photography CD" & CTLF & the time && the date & CTLF
  143.   if the number of chars in photosString then
  144.     put CTLF & CTLF & "You have downloaded the following photo files:" & CTLF & CTLF & photosString & CTLF & CTLF & copyright after indexText
  145.   end if
  146.   if userDeterminesDestination then
  147.     set indexFile to OpenAUserSelectFile()
  148.     updateStage()
  149.     if not objectp(indexFile) then
  150.       exit
  151.     end if
  152.     set folderOfFile to GetFolderOfFileName(fileName(indexFile))
  153.     set folderPath to MakeMovieFolderInLocation(folderOfFile)
  154.     set shortFolderPath to folderPath
  155.     delete char -30000 of shortFolderPath
  156.     put "Files below are located at" && shortFolderPath & CTLF before indexText
  157.   else
  158.     set folderPath to MakeMovieFolderOnDesktop()
  159.     if the platform contains "Windows" then
  160.       set indexFileName to " Index.txt"
  161.     else
  162.       set indexFileName to "Index"
  163.     end if
  164.     set indexFile to openAWriteFile(folderPath & indexFileName)
  165.   end if
  166.   writeString(indexFile, indexText)
  167.   if the platform contains "Mac" then
  168.     setFinderInfo(indexFile, "TEXT ttxt")
  169.   end if
  170.   set Copier to new(xtra("ProgressCopy"), 1, 1, 1)
  171.   repeat with photoFileName in downloadPhotoFiles
  172.     setStrings(Copier, "Downloading", photoFileName, "To Desktop")
  173.     set sourceRoot to the pathName & "Images" & slash()
  174.     set source to sourceRoot & photoFileName
  175.     set dest to folderPath & photoFileName
  176.     CopyFile(Copier, source, dest, 1, 1, 1)
  177.     put errorString(Copier)
  178.   end repeat
  179. end
  180.  
  181. on MakeMovieFolderOnDesktop
  182.   if the platform contains "Windows" then
  183.     set newFolderPath to getOSDirectory() & "\DESKTOP\" & pFolderName
  184.   else
  185.     set mainDrive to getAt(DrivesToList(), 1)
  186.     set newFolderPath to mainDrive & ":Desktop Folder:" & pFolderName
  187.   end if
  188.   CreateDirectory(newFolderPath)
  189.   return newFolderPath & slash()
  190. end
  191.  
  192. on MakeMovieFolderInLocation location
  193.   set newFolderPath to location & pFolderName
  194.   CreateDirectory(newFolderPath)
  195.   return newFolderPath & slash()
  196. end
  197.  
  198. on slash
  199.   if the platform contains "Windows" then
  200.     return "\"
  201.   else
  202.     return ":"
  203.   end if
  204. end
  205.  
  206. on openAWriteFile filePathName
  207.   set newFile to new(xtra("fileio"))
  208.   openFile(newFile, filePathName, 2)
  209.   if error(newFile, status(newFile)) = "OK" then
  210.     setPosition(newFile, getLength(newFile))
  211.     return newFile
  212.   else
  213.     createFile(newFile, filePathName)
  214.     openFile(newFile, filePathName, 2)
  215.     return newFile
  216.   end if
  217. end
  218.  
  219. on OpenAUserSelectFile
  220.   set newFile to new(xtra("fileio"))
  221.   set fileName to displaySave(newFile, "Save the index as:", "C:\index.txt")
  222.   if fileName = EMPTY then
  223.     return fileName
  224.   end if
  225.   createFile(newFile, fileName)
  226.   if error(newFile, status(newFile)) = "File Already Exits" then
  227.     openFile(newFile, fileName, 0)
  228.     DeleteFile(newFile)
  229.     closeFile(newFile)
  230.     createFile(newFile, fileName)
  231.   end if
  232.   openFile(newFile, fileName, 2)
  233.   return newFile
  234. end
  235.  
  236. on GetFolderOfFileName fileName
  237.   set previousItemDelimiter to the itemDelimiter
  238.   set the itemDelimiter to slash()
  239.   set numItems to the number of items in fileName - 1
  240.   set folder to item 1 to numItems of fileName & slash()
  241.   set the itemDelimiter to previousItemDelimiter
  242.   return folder
  243. end
  244.  
  245. on getBehaviorDescription me
  246.   set endChar to offset("--END OF HEADER", the text of me)
  247.   set endLine to the number of lines in char 1 to endChar of the text of me - 1
  248.   set description to line 1 to endLine of the text of me
  249.   repeat with whichLine = endLine down to 1
  250.     if line whichLine of description = EMPTY then
  251.       delete line whichLine of description
  252.     end if
  253.   end repeat
  254.   delete line 1 of description
  255.   return description
  256. end
  257.